package com.runshu.newsmartark.util;


import com.runshu.newsmartark.entity.InventoryEPCBean;
import com.runshu.newsmartark.reader.helper.InventoryBuffer;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Demo class
 *
 * @author yu
 * @date 2020/9/8
 * @decs：
 */

public class MTagRealList {

    private Map<String, InventoryBuffer.InventoryTagMap> data = new HashMap<>();


    public  final void addData(InventoryBuffer.InventoryTagMap bean) {
        if (bean.strEPC == null||bean.strEPC.length()>30) {
            return;
        }

//        for (InventoryEPCBean datum : data) {
//            if (bean.getEpc().equals(datum.getEpc())) {
//                return;
//            }
//        }
        data.put(bean.strEPC,bean);
    }
    public  final void addAllData(List<InventoryBuffer.InventoryTagMap> bean) {
        if (bean == null||bean.size()==0) {
            return;
        }

        for (InventoryBuffer.InventoryTagMap datum : bean) {
            if (datum.strEPC != null&&datum.strEPC.replace(" ", "").length()<30) {
                data.put(datum.strEPC, datum);
            }
        }

    }

    public List<InventoryBuffer.InventoryTagMap> getData(){
        ArrayList<InventoryBuffer.InventoryTagMap> inventoryEPCBeans = new ArrayList<>();
        inventoryEPCBeans.addAll(data.values());
        return inventoryEPCBeans ;
    }
    public int size(){
        if(data==null) return 0;
        return data.keySet().size();
    }
    public void clear(){
        data.clear();
    }
}